home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / messages.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  5.7 KB  |  177 lines

  1. #ifndef __STD_MESSAGE__
  2. #define __STD_MESSAGE__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * messages - Declarations for the Standard Library messaging facet
  8.  *
  9.  *
  10.  ***************************************************************************
  11.  *
  12.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  13.  * ALL RIGHTS RESERVED *
  14.  * The software and information contained herein are proprietary to, and
  15.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  16.  * intends to preserve as trade secrets such software and information.
  17.  * This software is furnished pursuant to a written license agreement and
  18.  * may be used, copied, transmitted, and stored only in accordance with
  19.  * the terms of such license and with the inclusion of the above copyright
  20.  * notice.  This software and information or any other copies thereof may
  21.  * not be provided or otherwise made available to any other person.
  22.  *
  23.  * Notwithstanding any other lease or license that may pertain to, or
  24.  * accompany the delivery of, this computer software and information, the
  25.  * rights of the Government regarding its use, reproduction and disclosure
  26.  * are as set forth in Section 52.227-19 of the FARS Computer
  27.  * Software-Restricted Rights clause.
  28.  *
  29.  * Use, duplication, or disclosure by the Government is subject to
  30.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  31.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  32.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  33.  * P.O. Box 2328, Corvallis, Oregon 97339.
  34.  *
  35.  * This computer software and information is distributed with "restricted
  36.  * rights."  Use, duplication or disclosure is subject to restrictions as
  37.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  38.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  39.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  40.  * then the "Alternate III" clause applies.
  41.  *
  42.  **************************************************************************/
  43.  
  44.  
  45. #ifndef __STD_RWLOCALE__
  46. #include "rw/rwlocale.h"
  47. #endif
  48.  
  49. #ifndef _RWSTD_NO_NAMESPACE
  50. namespace std {
  51. #endif
  52.  
  53. struct _RWSTDExport messages_base {
  54.   typedef int catalog;
  55. };
  56.  
  57. #ifndef _RWSTD_NO_NAMESPACE
  58. } namespace __rwstd {
  59. #endif
  60.  
  61. // --------------------------------------
  62. // Implementation class -- messages_impl.
  63. // --------------------------------------
  64.  
  65. class _RWSTDExport messages_impl {
  66.   string loc_name_;                          \
  67.  protected:
  68.   messages_impl (string name);
  69.  
  70.   messages_base::catalog open_cat_ (const string &,const locale &) const;
  71.   char *get_mess_ (messages_base::catalog,int,int) const;
  72.   const locale &get_loc_ (messages_base::catalog) const;
  73.   void close_cat_ (messages_base::catalog) const;
  74.   static string get_loc_name_ (const char*);
  75. };
  76.  
  77. #ifndef _RWSTD_NO_NAMESPACE
  78. } namespace std {
  79. #endif
  80.  
  81. // ----------------------------------------------------
  82. // Standard message retrieval facet -- messages<charT>.
  83. // ----------------------------------------------------
  84.  
  85. template <class charT>
  86. class  messages: public locale::facet, public messages_base,
  87.     public __RWSTD::messages_impl
  88. {
  89.  public:
  90.   typedef charT char_type;
  91.   typedef basic_string<charT,char_traits<charT>,allocator<charT> > string_type;
  92.  
  93.   _EXPLICIT messages (size_t refs=0);
  94.  
  95.   catalog open (const string& fn, const locale& loc) const
  96.     { return do_open(fn,loc); }
  97.   string_type get (catalog c, int set, int msgid, const string_type& df) const
  98.     { return do_get(c,set,msgid,df); }
  99.   void close (catalog c) const { do_close(c); }
  100.  
  101.   static locale::id id;
  102.  
  103.   // Implementation:
  104.   enum { facet_cat_ = locale::messages, ok_implicit_ = 1 };
  105.  
  106.  protected:
  107.   virtual ~messages();
  108.  
  109.   virtual catalog do_open (const string&, const locale&) const;
  110.   virtual string_type do_get (catalog, int, int, const string_type&) const;
  111.   virtual void do_close (catalog) const;
  112.  
  113.   // Implementation:
  114.   messages (size_t refs,string);
  115.  
  116.  private:
  117.   #ifdef _RWSTD_NO_MEMBER_TEMPLATES
  118.   locale::id &get_id (void) const { return id; }
  119.   #endif
  120. };
  121.  
  122. // -------------------------------------------------
  123. // Standard derived facet -- messages_byname<charT>.
  124. // -------------------------------------------------
  125.  
  126. template <class charT>
  127. class _RWSTDExportTemplate messages_byname: public messages<charT> {
  128.  public:
  129.   _EXPLICIT messages_byname (const char*, size_t refs=0);
  130.  
  131.  protected:
  132.  
  133.   // Virtual members inherited from messages<charT>:
  134.   // ~messages_byname();
  135.   // catalog do_open (const string&, const locale&) const;
  136.   // string_type do_get (catalog, int, int, const string_type&) const;
  137.   // void do_close (catalog) const;
  138. };
  139.  
  140. #ifndef _RWSTD_NO_NAMESPACE
  141. } namespace __rwstd {
  142. #endif
  143.  
  144. #ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
  145.  
  146. template <class charT>
  147. inline messages<charT>* _RWSTDExport create_named_facet
  148.     (messages<charT>*,const char *name,size_t refs)
  149. { return new messages_byname<charT>(name,refs); }
  150.  
  151. #else
  152. _RWSTD_TEMPLATE
  153. inline _STD::messages<char>* _RWSTDExport create_named_facet
  154.     (_STD::messages<char>*,const char *name,size_t refs)
  155. { return new messages_byname<char>(name,refs); }
  156.  
  157. #ifndef _RWSTD_NO_WIDE_CHAR
  158. _RWSTD_TEMPLATE
  159. inline _STD::messages<wchar_t>* _RWSTDExport create_named_facet
  160.     (_STD::messages<wchar_t>*,const char *name,size_t refs)
  161. { return new messages_byname<wchar_t>(name,refs); }
  162.  
  163. #endif // _RWSTD_NO_WIDE_CHAR
  164. #endif // _RWSTD_NO_FUNC_PARTIAL_SPEC
  165.  
  166.  
  167. #ifndef _RWSTD_NO_NAMESPACE
  168. } // namespace __rwstd
  169. #endif
  170.  
  171. #ifdef _RWSTD_COMPILE_INSTANTIATE
  172. #include <rw/messages.cc>
  173. #endif
  174.  
  175. #pragma option pop
  176. #endif /* __STD_MESSAGE__ */
  177.